<template>
  <!-- 用户管理 -->
  
  <div id="User" class="User">
     <h1>
      用户管理
    </h1>
    <template>
      <el-table :data="list" border style="width: 100%">
        <el-table-column prop="id" label="ID" width="180"></el-table-column>
        <el-table-column prop="username" label="用户名" width="180"></el-table-column>
        <el-table-column prop="email" label="邮箱"></el-table-column>
        <el-table-column prop="phone" label="电话"></el-table-column>
        <el-table-column prop="createTime" :formatter="dateFormat" label="注册时间"></el-table-column>
      </el-table>
      <paging :total="total" @sorter="handleCurrentChange"></paging>
    </template>
  </div>
</template>

<script>
import { Userlist } from "@/request/http";
import { Userpage } from "@/request/http";
import paging from "@/pages/home/components/paging";

export default {
  props: {},
  name: "User",
  data() {
    return {
      list: [],
      total: 5,
    };
  },
  created() {},
  computed: {},
  components: {
    // 组件的引用
    paging,
  },
  methods: {
    // 方法集合
    // 时间转换格式插件
    dateFormat: function (row, column) {
      var date = row[column.property];
      if (date === undefined) {
        return "";
      }
      var moment = require("moment");
      return moment(date).format("YYYY-MM-DD HH:mm:ss");
    },
    // 分页功能
    handleCurrentChange(val) {
      Userpage(val).then((data) => {
        // console.log(data.data);
        this.list = data.data.data.list;
        // console.log(this.Shoplist);
      });
    },
  },
  mounted() {
    // 页面进入时加载内容
    // 数据请求
    Userlist.then((data) => {
      if (data.data.status == 0) {
        // console.log(data);
        this.list = data.data.data.list;
        this.total = data.data.data.total;
        // console.log(this.list);
      }
    });
  },
  watch: {},
};
</script>
<style lang="scss" scoped >
h1 {
  font-size: 50px;
  padding: 40px;
  display: flex;
}
</style>